package com.zige.zige.operationgudie;

import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.zige.zige.R;
import com.zige.zige.activity.RegisterActivity;
import com.zige.zige.utils.SharedPreferencesUtils;

/**
 * 主页去注册引导
 * Created by Fei on 2016/3/15.
 */
public class MainOperateDialog extends android.support.v4.app.DialogFragment {

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        View view = inflater.inflate(R.layout.dialog_main_operate, container);
        getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        Window window = getDialog().getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        window.setGravity(Gravity.BOTTOM);
        window.setAttributes(lp);
        getDialog().show();
        getDialog().setCanceledOnTouchOutside(true);
        getDialog().setCancelable(true);
        SharedPreferencesUtils.saveValue(getActivity(),SharedPreferencesUtils.main_registe_operate_guide,true);
        LinearLayout lay_all = (LinearLayout) view.findViewById(R.id.lay_all);
        lay_all.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getDialog().dismiss();
                SharedPreferencesUtils.saveValue(getActivity(),SharedPreferencesUtils.main_registe_operate_guide,true);
            }
        });
        ImageView img_go_register = (ImageView) view.findViewById(R.id.img_go_register);
        img_go_register.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SharedPreferencesUtils.saveValue(getActivity(),SharedPreferencesUtils.main_registe_operate_guide,true);
                Intent intent  = new Intent();
                intent.setClass(getActivity(), RegisterActivity.class);
                intent.putExtra("dialog","1");
                startActivity(intent);
                dismiss();
            }
        });


        return view;

    }
}
